﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
using IQReportes.ViewModels;

namespace IQReportes.Models
{
    public class PerfilXModulo
    {

        [Key, Column(Order = 1, TypeName = "int")]
        public int idPerfil { get; set; }
        [ForeignKey("idPerfil")]
        public Perfil perfil { get; set; }

        [Key, Column(Order = 2, TypeName = "int")]
        public int idModulo { get; set; }
        [ForeignKey("idModulo")]
        public Modulo modulo { get; set; }

        public bool bVer { get; set; }
        public bool bDescargar { get; set; }

        public PerfilXModulo(){}
        
        public PerfilXModulo(Perfil nuevoPerfil, ModuloInfoViewModel moduloView,int tipo , int numModulo)
        {
            this.idPerfil = nuevoPerfil.idPerfil;
            this.perfil = nuevoPerfil;
            Modulo m = moduloView.extract(tipo, numModulo);
            this.idModulo = m.idModulo;
            this.modulo = new Modulo { idModulo = Int32.Parse( moduloView.id) };
            this.bVer = moduloView.ver;
            this.bDescargar = moduloView.descargar;
        }
    }   
}